import numpy as np
import json
from sklearn import model_selection as mo
from sklearn import svm
from sklearn.metrics import classification_report
from sklearn.model_selection import GridSearchCV
# 自添
import matplotlib
matplotlib.use('TkAgg')
# 自添结束
import matplotlib.pyplot as plt
import skimage
from matplotlib.font_manager import FontManager, FontProperties
import matplotlib.font_manager as fm
def getChineseFont():
    return FontProperties(fname='/System/Library/Fonts/PingFang.ttc')
myfont = fm.FontProperties(fname='/System/Library/Fonts/PingFang.ttc')

file1 = "./s1-3d-real2.json"
file2 = "./s2-3d-real2.json"
file3 = "./s3attack-3d-attack2.json"
# file4 = "./test_release-fasd-ycbcr-hsv-attack.json"


# file = "./video.json"

y = []
y2 = []
for i in range(110):
  y.append(i)

for i in range(60):
  y2.append(i)
# y = np.array(y)
x_train = []
x_test = []
y_train = []
y_test = []



with open(file1, 'r')as f:
    list = json.load(f)
    data1 = np.array(list)

with open(file2, 'r')as f:
    list = json.load(f)
    data2 = np.array(list)

with open(file3, 'r')as f:
    list = json.load(f)
    data3 = np.array(list)

# with open(file4, 'r')as f:
#     list = json.load(f)
#     data4 = np.array(list)

# 训练集
for i in range(len(data1)):
    x_train.append(np.array([data1[i]]))
    # y_train.append(0)
    
for i in range(len(data2)):
    x_train.append(np.array([data2[i]]))
    # y_train.append(1)

# 测试集
for i in range(len(data3)):
    x_test.append(np.array([data3[i]]))
    # y_test.append(0)
    
# for i in range(len(data4)):
#     x_test.append(np.array([data4[i]]))
#     y_test.append(1)
# print(len(x_train),len(y2))

plt.scatter(x_train, y, s=110, c='b',)#真实人脸 蓝色
plt.scatter(x_test, y2, s=60, c='r',) #伪造人脸 红色
plt.xlabel('相关系数',fontproperties=getChineseFont(),fontsize=14)  # x轴标题
plt.ylabel('人脸编号',fontproperties=getChineseFont(),fontsize=14)  # y轴标题
# plt.plot()
plt.legend(["真实人脸","伪造人脸"],prop=myfont)

plt.show()

